﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Settlement.aspx.cs" Inherits="Maticsoft.Web.Settlement" %>

<%@ Register Src="footer.ascx" TagName="footer" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>订单结算</title>
    <link rel="stylesheet" href="css/reset.css" />
    <link rel="stylesheet" href="css/common.css" />
    <script src="js/jquery-1.8.2.js" type="text/javascript"></script>
    <script src="js/layer/layer.js" type="text/javascript"></script>
    <script type="text/javascript">
        function Addr() {
            $.layer({
                type: 2,
                title: '收货地址',
                iframe: { src: 'Addr.aspx?ids=' + $("#hidProductIds").val() },
                area: ['700px', '500px'],
                offset: ['50px', '']
            });
        }

        function SetAddr(id) {
            $("span[id^='addr']").css("border", "0px");
            $("#addr" + id).css("border", "2px solid #E4393C");
            $("#hidDeliveryId").val(id);
        }

        function AddOrder() {
            if ($("#hidDeliveryId").val() == "") {
                alert("请选择配送地址");
                return;
            }
            $.ajax({
                type: "get",
                url: "Settlement.aspx",
                data: "sync=true&ids=" + $("#hidProductIds").val() + "&delivery=" + $("#hidDeliveryId").val() + "&payway=&d=" + new Date().toString(),
                success: function (msg) {
                    var obj = eval('(' + msg + ')');
                    if (obj.code == "1") {
                        //alert("订单提交成功");
                        window.location.href = "/pay/alipay/default.aspx?orderid=" + obj.data.orderid + "&fee=" + obj.data.total + "&name=" + escape("购买商品") + "&remark=";
                    }
                },
                error: function (msg) {
                    alert("出错啦");
                }
            })
        }

        $(function () {
            if ($("#hidDeliveryId").val() != "") {
                SetAddr($("#hidDeliveryId").val());
            }
        })
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="row bg-garay">
        <div class="safe_width">
            <div class="fr linkbox">
                <%if (Session["UserId"] == null || Session["UserId"] == "")
                  { %><a href="Login.aspx">登录</a><span>|</span> <a href="Register.aspx">注册</a><%}
                  else
                  {%><a href="UserAccount.aspx"><%=Session["ManagerName"]%></a><span>|</span> <a href="Logout.aspx">
                      退出</a><span><%} %>|</span> <a href="UserOrder.aspx">我的订单</a><span>|</span>
                <a href="ShoppingCar.aspx">
                    <img src="img/top-cat.png">购物车</a><span>|</span> <a href="#">
                        <img src="img/top-iphone.png">移动商城</a><span>|</span>
            </div>
        </div>
    </div>
    <div class="row bg-white">
        <div class="safe_width">
            <div class="logo fl">
                <img src="img/logo.png" style="cursor: pointer" onclick="window.location.href='default.aspx'">
                <span class="other">结算页</span>
            </div>
            <div class="stepbox fr">
                <div class="step hover">
                    <p class="fs-12 tc tc-white line-hei-24">
                        1</p>
                    <p class="line-hei-30">
                        1.我的购物车</p>
                </div>
                <div class="step active">
                    <p class="fs-12 tc tc-white line-hei-24">
                        2</p>
                    <p class="line-hei-30">
                        2.填写核对订单信息</p>
                </div>
                <div class="step">
                    <p class="fs-12 tc tc-white line-hei-24">
                        3</p>
                    <p class="line-hei-30">
                        3.成功提交订单</p>
                </div>
            </div>
        </div>
    </div>
    <div class="row bg-white">
        <div class="safe_width">
            <div class="sett-tit">
                填写并核对订单信息
            </div>
            <div class="borderbox sett-mian">
                <div class="shop-car-indent">
                    <div class="row line-hei-30">
                        <p class="fs-14 tc-black fb fl line-hei-30">
                            收货人信息</p>
                        <p class="fs-12 tc-blue fr line-hei-30" style="cursor: pointer" onclick="Addr();">
                            新增收货地址</p>
                    </div>
                    <div class="row pad-10">
                        <asp:Repeater ID="Repeater1" runat="server">
                            <ItemTemplate>
                                <div class="equal-1 fl tl">
                                    <span id="addr<%#Eval("DeliveryId") %>" class="Default fs-12 tc-black fl" style="width: 110px;
                                        cursor: pointer; border: 0px;" onclick="SetAddr(<%#Eval("DeliveryId") %>);">
                                        <%#Eval("Name")%></span>
                                </div>
                                <div class="equal-2 fl tl fs-12 tc-gray line-hei-30" style="width: 52%">
                                    <p class="mar-rig-10 fl">
                                        <%#Eval("Name")%></p>
                                    <p class="mar-rig-30 fl">
                                        <%#GetLocation(Eval("locationId")) + " " + Eval("Address")%></p>
                                    <p class="fl mar-rig-10">
                                        <%#Eval("Mobile")%></p>
                                </div>
                            </ItemTemplate>
                        </asp:Repeater>
                        <input id="hidDeliveryId" runat="server" type="hidden" />
                        <!--<div class="equal-1 fl tc fs-12 tc-black line-hei-30">
                            更多地址</div>-->
                    </div>
                </div>
                <div class="shop-car-indent">
                    <div class="row line-hei-30">
                        <p class="fs-14 tc-black fb fl line-hei-30">
                            支付方式</p>
                    </div>
                    <div class="row pad-10">
                        <div class="equal-1 fl tl">
                            <span class="Default fs-12 tc-black fl">支付宝</span>
                        </div>
                    </div>
                </div>
                <div class="shop-car-indent">
                    <div class="row ">
                        <p class="fs-14 tc-black fb fl line-hei-30">
                            送货清单</p>
                    </div>
                    <div class="row" style="padding: 20px 20px 30px 20px; line-height: 24px;">
                        <div class="fl" style="width: 100%">
                            <div class="fs-12 tc-black fl tc" style="width: 30%">
                                商品名称</div>
                            <div class="fs-12 tc-black fl tc" style="width: 20%">
                                规格</div>
                            <div class="fs-12 tc-black fl tc" style="width: 12%">
                                单价</div>
                            <div class="fs-12 tc-black fl tc" style="width: 16%">
                                数量</div>
                            <div class="fs-12 tc-black fl tc" style="width: 14%">
                                小计</div>
                        </div>
                    </div>
                    <asp:Repeater ID="Repeater2" runat="server">
                        <ItemTemplate>
                            <div class="row mar-btm-10">
                                <div class="equal-2 fl">
                                    <p class="fl">
                                        <img class="borderbox" src="uploadpic/<%#Eval("Pic") %>" width="80" height="80" alt="">
                                    </p>
                                    <div class="equal-2 fl tc-black pad-10">
                                        <p>
                                            <%#Eval("ProductName") %></p>
                                    </div>
                                    <div class="equal-1 fl tc-gray tc" style="text-align:left">
                                        <p>
                                            规格：<%#Eval("ProductDesc")%></p>
                                        <%#Maticsoft.Common.DigitHelper.GetInt32(Eval("Weight")) > 0 ? "<p>重量：" + Eval("Weight") + "</p>" : ""%>
                                    </div>
                                </div>
                                <div class="equal-2 fl">
                                    <div class="equal-1-3 tc-black fl tc line-hei-80 fb tc-red" style="width: 30%">
                                        <%#Eval("SalePrice")%></div>
                                    <div class="equal-1-3 tc-black fl tc" style="width: 30%">
                                        <p class="des-no">
                                            <%#Eval("ProductNum") %>
                                        </p>
                                    </div>
                                    <div class="equal-1-3 tc-black fl tc line-hei-80 fb tc-red" style="width: 30%">
                                        <%#(decimal.Parse(Eval("SalePrice").ToString()) * int.Parse(Eval("ProductNum").ToString())).ToString("f2")%></div>
                                </div>
                            </div>
                        </ItemTemplate>
                    </asp:Repeater>
                </div>
                <div class="shop-car-indent" style="display: none">
                    <div class="row line-hei-30">
                        <p class="fs-14 tc-black fb fl">
                            发票信息</p>
                    </div>
                    <div class="row pad-10">
                        <span class="fs-12 tc-gray fl line-hei-30 mar-rig-10">普通发票 </span><span class="fs-12 tc-gray fl line-hei-30 mar-rig-10">
                            个人 </span><span class="fs-12 tc-gray fl line-hei-30 mar-rig-10">明细 </span>
                        <!--<a href="#"
                                class="fs-12 tc-blue fl line-hei-30">修改</a>-->
                    </div>
                </div>
            </div>
            <div class="borderbox pad-10" style="background-color: #f9f9f9;">
                <div class="equal-2 fr  pad-10">
                    <div class="equal-3 fl tr">
                        <p class="fs-12 tc-gray line-hei-20">
                            <asp:Literal ID="ltlNum" runat="server"></asp:Literal>件商品，总商品金额：</p>
                        <!--<p class="fs-12 tc-gray line-hei-20">
                            优惠:</p>-->
                        <p class="fs-12 tc-gray line-hei-20">
                            运费：</p>
                    </div>
                    <div class="equal-1 fl tl">
                        <p class="fs-12 tc-gray line-hei-20">
                            ￥<asp:Literal ID="ltlProductPrice" runat="server"></asp:Literal></p>
                        <!--<p class="fs-12 tc-gray line-hei-20">
                            ￥18.00</p>-->
                        <p class="fs-12 tc-gray line-hei-20">
                            ￥<asp:Literal ID="ltlDeliveryFee" runat="server"></asp:Literal></p>
                    </div>
                </div>
            </div>
            <div class="row">
                <p style="margin: 20px 0;" class="tr fs-12 tc-black line-hei-30">
                    应付总额：<span class="fs-20 tc-red">￥<asp:Literal ID="ltlTotal" runat="server"></asp:Literal></span></p>
                <div class="des-buy fr">
                    <input id="hidProductIds" type="hidden" runat="server" />
                    <button class="shop-car" type="button" onclick="AddOrder();">
                        提交订单
                    </button>
                </div>
            </div>
        </div>
    </div>
    <uc1:footer ID="footer1" runat="server" />
    </form>
</body>
</html>
